﻿namespace Dissemination.MVC.Repositories
{
    using System.Collections.Specialized;
    using System.Linq;
    using System.Collections.Generic;
    using System.Web.UI.WebControls;

    using Models;

    public class FollowUpRepository : BaseRepository<FollowUp>
    {
        public FollowUpRepository()
        {
            EntityName = "FollowUps";
        }

        public override List<FollowUp> List()
        {
            return dataContext.FollowUps.ToList();
        }

        public List<FollowUp> ListBySeminarID(int seminarID)
        {
            return dataContext.FollowUps.Include("ProfessionalBackground").Include("Gender").Where(f => f.Seminar.SeminarID == seminarID).ToList();
        }

        public Seminar GetSeminarByID(int seminarID)
        {
            return dataContext.Seminars.Include("TargetArea.Country").Include("TargetArea.Program").Include("Participants").Include("FollowUps.Gender").Include("FollowUps.ProfessionalBackground").Include("FollowUps.Speciality").FirstOrDefault(s => s.SeminarID == seminarID);
        }

        public override FollowUp Get(int id)
        {
            return dataContext.FollowUps.Include("Seminar").Include("Gender").Include("ProfessionalBackground").Include("Speciality").FirstOrDefault(f => f.FollowUpID == id);
        }

        public Gender GetGenderByID(int genderId)
        {
            return dataContext.Genders.FirstOrDefault(g => g.GenderID == genderId);
        }

        public List<Gender> GetGendersList()
        {
            return dataContext.Genders.ToList();
        }

        public ListItemCollection GetRoles()
        {
            var collection = new ListItemCollection
                                 {
                                         new ListItem("-", "1"),
                                         new ListItem("Critical care, ICU, Emergency room or recovery room", "2"),
                                         new ListItem("Donor coordinator", "3"), 
                                         new ListItem("Procurement Team: anaesthesia", "4"), 
                                         new ListItem("Procurement Team: surgery", "5"), 
                                         new ListItem("Recipients transplant coordinator", "6"),
                                         new ListItem("Others", "7")
                                 };
            return collection;
        }

        public ListItemCollection GetAttitudes()
        {
            var collection = new ListItemCollection
                                 {
                                         new ListItem("Strongly disagree", "1"),
                                         new ListItem("Somewhat disagree", "2"),
                                         new ListItem("Neither agree nor disagree", "3"),
                                         new ListItem("Somewhat agree", "4"),
                                         new ListItem("Strongly agree", "5"),
                                 };
            return collection;
        }

        public ProfessionalBackground GetProfessionalBackgroundByID(int professionalBackgroundID)
        {
            return
                dataContext.ProfessionalBackgrounds.FirstOrDefault(
                pb => pb.ProfessionalBackgroundID == professionalBackgroundID);
        }

        public Speciality GetSpecialityByID(int specialityID)
        {
            return
                dataContext.Specialities.FirstOrDefault(
                s => s.SpecialityID == specialityID);
        }

        public List<Speciality> ListSpecialities()
        {
            return dataContext.Specialities.ToList();
        }

        public List<ProfessionalBackground> ListProfessionalBackgrounds()
        {
            return dataContext.ProfessionalBackgrounds.ToList();
        }

    }
}
